const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

// user-agent 把浏览器的UserAgent变成一个对象

module.exports = {
    entry: './src/index.js',//入口文件
    context: process.cwd(),//上下文目录
    mode: 'development',//开发模式
    output: {
        path: path.resolve(__dirname, 'dist'),//输出目录
        filename: 'monitor.js' //文件名
    },
    devServer: {
        static: path.resolve(__dirname, 'public'),//静态文件目录
        setupMiddlewares: (middlewares, devServer) => {
            devServer.app.get('/success', (req, res) => {
                res.send({ custom: '666' });
            })
            devServer.app.get('/error', (req, res) => {
                res.send(500);
            })
            return middlewares;
        }
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html',
            inject: 'head'
        })
    ]
} 